<?php


namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class MenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return mixed
     */
    public function run()
    {
        return $this->insert([
            [
                'path' => '/task/manage',
                'component' => '#',
                'redirect' => '/task/manage/papper',
                'name' => 'TaskManage',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '任务管理',
                'meta' => [
                    'title' => '任务管理',
                    'icon' => 'ep:management',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'papper',
                        'component' => 'views/Task/Manage/PapperTaskManage',
                        'name' => 'PapperTaskManage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文案任务',
                        'meta' => [
                          'title' => '文案任务'
                        ]
                    ],
                    [
                        'path' => 'audio',
                        'component' => 'views/Task/Manage/AudioTaskManage',
                        'name' => 'AudioTaskManage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '音频任务',
                        'meta' => [
                          'title' => '音频任务'
                        ]
                    ],
                    [
                        'path' => 'clip',
                        'component' => 'views/Task/Manage/ClipTaskManage',
                        'name' => 'ClipTaskManage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '剪辑任务',
                        'meta' => [
                          'title' => '剪辑任务'
                        ]
                    ],
                    [
                        'path' => 'publish',
                        'component' => 'views/Task/Manage/PublishTaskManage',
                        'name' => 'PublishTaskManage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '发布任务',
                        'meta' => [
                          'title' => '发布任务'
                        ]
                    ],
                ]
            ],
            [
                'path' => '/papper',
                'component' => '#',
                'redirect' => '/papper/list',
                'name' => 'PapperManage',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '文案编辑',
                'meta' => [
                    'title' => '文案编辑',
                    'icon' => 'ep:management',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'list',
                        'component' => 'views/Papper/PapperList',
                        'name' => 'PapperList',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文案列表',
                        'meta' => [
                          'title' => '文案列表'
                        ]
                    ],
                    [
                        'path' => 'papper-edit',
                        'component' => 'views/Papper/PapperEdit',
                        'name' => 'PapperEdit',
                        'status' => 1,
                        'type' => 1,
                        'title' => '编辑文案',
                        'meta' => [
                            'title' => '编辑文案',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true
                        ]
                    ],
                    [
                        'path' => 'account',
                        'component' => 'views/Property/Account/Account',
                        'name' => 'Account',
                        'status' => 1,
                        'type' => 1,
                        'title' => '账号列表',
                        'meta' => [
                            'title' => '账号列表'
                        ]
                    ],
                    [
                        'path' => 'folder',
                        'component' => 'views/Property/Folder/Folder',
                        'name' => 'Folder',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文件夹管理',
                        'meta' => [
                          'title' => '文件夹管理'
                        ]
                    ]
                ]
            ],
            [
                'path' => '/clip',
                'component' => '#',
                'redirect' => '/clip/list',
                'name' => 'Clip',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '视频剪辑',
                'meta' => [
                    'title' => '视频剪辑',
                    'icon' => 'ep:management',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'list',
                        'component' => 'views/Clip/ClipList',
                        'name' => 'ClipList',
                        'status' => 1,
                        'type' => 1,
                        'title' => '视频列表',
                        'meta' => [
                          'title' => '视频列表'
                        ]
                    ],
                    [
                        'path' => 'videos',
                        'component' => 'views/Property/Video/Video',
                        'name' => 'Video',
                        'status' => 1,
                        'type' => 1,
                        'title' => '视频素材',
                        'meta' => [
                          'title' => '视频素材'
                        ]
                    ],
                    [
                        'path' => 'product',
                        'component' => 'views/Property/Product/Product',
                        'name' => 'Product',
                        'status' => 1,
                        'type' => 1,
                        'title' => '成品列表',
                        'meta' => [
                          'title' => '成品列表'
                        ]
                    ],
                    [
                        'path' => 'tag',
                        'component' => 'views/Clip/ClipTag',
                        'name' => 'ClipTag',
                        'status' => 1,
                        'type' => 1,
                        'title' => '视频打标',
                        'meta' => [
                          'title' => '视频打标'
                        ]
                    ],
                    [
                        'path' => 'start',
                        'component' => 'views/Clip/ClipStart',
                        'name' => 'ClipStart',
                        'status' => 1,
                        'type' => 1,
                        'title' => '开始剪辑',
                        'meta' => [
                            'title' => '开始剪辑',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true
                        ]
                    ],
                    [
                        'path' => 'footage',
                        'component' => 'views/Clip/ClipFootage',
                        'name' => 'ClipFootage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '编辑镜头组',
                        'meta' => [
                            'title' => '编辑镜头组',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true
                        ]
                    ],
                    [
                        'path' => 'video',
                        'component' => 'views/Clip/ClipVideo',
                        'name' => 'ClipVideo',
                        'status' => 1,
                        'type' => 1,
                        'title' => '找素材',
                        'meta' => [
                            'title' => '找素材',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true
                        ]
                    ]
                ]
            ],
            [
                'path' => '/task/accept',
                'component' => '#',
                'redirect' => '/task/accept/papper',
                'name' => 'TaskAccept',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '任务接单',
                'meta' => [
                    'title' => '任务接单',
                    'icon' => 'ep:management',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'papper',
                        'component' => 'views/Task/Accept/PapperTaskAccept',
                        'name' => 'PapperTaskAccept',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文案任务',
                        'meta' => [
                          'title' => '文案任务'
                        ]
                    ],
                    [
                        'path' => 'audio',
                        'component' => 'views/Task/Accept/AudioTaskAccept',
                        'name' => 'AudioTaskAccept',
                        'status' => 1,
                        'type' => 1,
                        'title' => '音频任务',
                        'meta' => [
                          'title' => '音频任务'
                        ]
                    ],
                    [
                        'path' => 'clip',
                        'component' => 'views/Task/Accept/ClipTaskAccept',
                        'name' => 'ClipTaskAccept',
                        'status' => 1,
                        'type' => 1,
                        'title' => '剪辑任务',
                        'meta' => [
                          'title' => '剪辑任务'
                        ]
                    ],
                    [
                        'path' => 'publish',
                        'component' => 'views/Task/Accept/PublishTaskAccept',
                        'name' => 'PublishTaskAccept',
                        'status' => 1,
                        'type' => 1,
                        'title' => '发布任务',
                        'meta' => [
                          'title' => '发布任务'
                        ]
                    ],
                ]
            ],
            [
                'path' => '/authorization',
                'component' => '#',
                'redirect' => '/authorization/user',
                'name' => 'Authorization',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '权限管理',
                'meta' => [
                    'title' => '权限管理',
                    'icon' => 'eos-icons:role-binding',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'user',
                        'component' => 'views/Authorization/User/User',
                        'name' => 'User',
                        'status' => 1,
                        'type' => 1,
                        'title' => '用户管理',
                        'meta' => [
                          'title' => '用户管理'
                        ]
                    ],
                    [
                        'path' => 'menu',
                        'component' => 'views/Authorization/Menu/Menu',
                        'name' => 'Menu',
                        'status' => 1,
                        'type' => 1,
                        'title' => '菜单管理',
                        // 'permission' => [['label' => '新增', 'value' => 'add'], ['label' => '修改', 'value' => 'edit'], ['label' => '删除', 'value' => 'delete']],
                        'meta' => [
                          'title' => '菜单管理'
                        //   'permission' => ['add', 'edit', 'delete']
                        ]
                    ],
                    [
                        'path' => 'role',
                        'component' => 'views/Authorization/Role/Role',
                        'name' => 'Role',
                        'status' => 1,
                        'type' => 1,
                        'title' => '角色管理',
                        'meta' => [
                          'title' => '角色管理'
                        ]
                    ]
                ]
            ],
            [
                'path' => '/property',
                'component' => '#',
                'redirect' => '/property/account',
                'name' => 'Property',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '属性管理',
                'meta' => [
                    'title' => '属性管理',
                    'icon' => 'eos-icons:role-binding',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'account',
                        'component' => 'views/Property/Account/Account',
                        'name' => 'AccountP',
                        'status' => 1,
                        'type' => 1,
                        'title' => '账号管理',
                        'meta' => [
                          'title' => '账号管理'
                        ]
                    ],
                    [
                        'path' => 'ip',
                        'component' => 'views/Property/Ip/Ip',
                        'name' => 'Ip',
                        'status' => 1,
                        'type' => 1,
                        'title' => 'Ip管理',
                        'meta' => [
                          'title' => 'Ip管理'
                        ]
                    ],
                    [
                        'path' => 'platform',
                        'component' => 'views/Property/Platform/Platform',
                        'name' => 'Platform',
                        'status' => 1,
                        'type' => 1,
                        'title' => '平台管理',
                        'meta' => [
                          'title' => '平台管理'
                        ]
                    ],
                    [
                        'path' => 'audio',
                        'component' => 'views/Property/Audio/Audio',
                        'name' => 'Audio',
                        'status' => 1,
                        'type' => 1,
                        'title' => '音频管理',
                        'meta' => [
                          'title' => '音频管理'
                        ]
                    ],
                    [
                        'path' => 'folder',
                        'component' => 'views/Property/Folder/Folder',
                        'name' => 'FolderP',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文件夹管理',
                        'meta' => [
                          'title' => '文件夹管理'
                        ]
                    ],
                    [
                        'path' => 'footage',
                        'component' => 'views/Property/Footage/Footage',
                        'name' => 'Footage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '镜头组管理',
                        'meta' => [
                          'title' => '镜头组管理'
                        ]
                    ],
                    [
                        'path' => 'papper',
                        'component' => 'views/Property/Papper/Papper',
                        'name' => 'Papper',
                        'status' => 1,
                        'type' => 1,
                        'title' => '文案管理',
                        'meta' => [
                          'title' => '文案管理'
                        ]
                    ],
                    [
                        'path' => 'part',
                        'component' => 'views/Property/Part/Part',
                        'name' => 'Part',
                        'status' => 1,
                        'type' => 1,
                        'title' => '分镜头管理',
                        'meta' => [
                          'title' => '分镜头管理'
                        ]
                    ],
                    [
                        'path' => 'product',
                        'component' => 'views/Property/Product/Product',
                        'name' => 'ProductP',
                        'status' => 1,
                        'type' => 1,
                        'title' => '成品管理',
                        'meta' => [
                          'title' => '成品管理'
                        ]
                    ],
                    [
                        'path' => 'tag',
                        'component' => 'views/Property/Tag/Tag',
                        'name' => 'Tag',
                        'status' => 1,
                        'type' => 1,
                        'title' => '标签管理',
                        'meta' => [
                          'title' => '标签管理'
                        ]
                    ],
                    [
                        'path' => 'task',
                        'component' => 'views/Property/Task/Task',
                        'name' => 'Task',
                        'status' => 1,
                        'type' => 1,
                        'title' => '任务管理',
                        'meta' => [
                          'title' => '任务管理'
                        ]
                    ],
                    [
                        'path' => 'video',
                        'component' => 'views/Property/Video/Video',
                        'name' => 'VideoP',
                        'status' => 1,
                        'type' => 1,
                        'title' => '视频管理',
                        'meta' => [
                          'title' => '视频管理'
                        ]
                    ]
                ]
            ],
            [
                'path' => '/example',
                'component' => '#',
                'redirect' => '/example/example-dialog',
                'name' => 'Example',
                'status' => 1,
                'type' => 0,
                'pid' => null,
                'title' => '综合示例',
                'meta' => [
                    'title' => '综合示例',
                    'icon' => 'ep:management',
                    'alwaysShow' => true
                ],
                'children' => [
                    [
                        'path' => 'example-dialog',
                        'component' => 'views/Example/Dialog/ExampleDialog',
                        'name' => 'ExampleDialog',
                        'status' => 1,
                        'type' => 1,
                        'title' => '综合示例-弹窗',
                        'meta' => [
                          'title' => '综合示例-弹窗'
                        ]
                    ],
                    [
                        'path' => 'example-page',
                        'component' => 'views/Example/Page/ExamplePage',
                        'name' => 'ExamplePage',
                        'status' => 1,
                        'type' => 1,
                        'title' => '综合示例-页面',
                        'permission' => [['label' => '新增', 'value' => 'add'], ['label' => '修改', 'value' => 'edit']],
                        'meta' => [
                            'title' => '综合示例-页面',
                            'permission' => ['add', 'edit']
                        ]
                    ],
                    [
                        'path' => 'example-add',
                        'component' => 'views/Example/Page/ExampleAdd',
                        'name' => 'ExampleAdd',
                        'status' => 1,
                        'type' => 1,
                        'title' => '综合示例-新增',
                        'meta' => [
                            'title' => '综合示例-新增',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true,
                            'activeMenu' => '/example/example-page'
                        ]
                    ],
                    [
                        'path' => 'example-edit',
                        'component' => 'views/Example/Page/ExampleEdit',
                        'name' => 'ExampleEdit',
                        'status' => 1,
                        'type' => 1,
                        'title' => '综合示例-编辑',
                        'meta' => [
                            'title' => '综合示例-编辑',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true,
                            'activeMenu' => '/example/example-page'
                        ]
                    ],
                    [
                        'path' => 'example-detail',
                        'component' => 'views/Example/Page/ExampleDetail',
                        'name' => 'ExampleDetail',
                        'status' => 1,
                        'type' => 1,
                        'title' => '综合示例-详情',
                        'meta' => [
                            'title' => '综合示例-详情',
                            'noTagsView' => true,
                            'noCache' => true,
                            'hidden' => true,
                            'showMainRoute' => true,
                            'activeMenu' => '/example/example-page'
                        ]
                    ]
                ]
            ]
        ]);
    }

    /**
     * 插入数据
     *
     * @param array $menus
     * @param int $pid
     * @return bool
     */
    public function insert(array $menus, int $pid = 0) {
        foreach ($menus as $menu) {
            $data = [
                'path' => isset($menu['path']) ? $menu['path'] : '',
                'component' => isset($menu['component']) ? $menu['component'] : '',
                'title' => isset($menu['title']) ? $menu['title'] : '',
                'redirect' => isset($menu['redirect']) ? $menu['redirect'] : '',
                'name' => isset($menu['name']) ? $menu['name'] : '',
                'status' => 1,
                'type' => $menu['type'],
                'pid' => $pid,
                'permission' => isset($menu['permission']) ? json_encode($menu['permission'], JSON_UNESCAPED_UNICODE) : null,
                'meta' => isset($menu['meta']) ? json_encode($menu['meta'], JSON_UNESCAPED_UNICODE) : null,
                'sort' => isset($menu['sort']) ? $menu['sort'] : 50,
                'created_at' => date('Y-m-d H:i:s')
            ];
            $id = DB::table('menus')->insertGetId($data);
            if (isset($menu['children']) && count($menu['children']) > 0) {
                $this->insert($menu['children'], $id);
            }
        }
        return true;
    }
}
